﻿using AttributeRouting.Web.Http;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using Water.Model;

namespace Water.RestService.Controllers
{
    public class SmallValveOperateController : ApiController
    {
        
        private SmallValveOperateQuery svoq;
        private SmallValveOperate svo;

        [POST("GetSmallValveOperates")]
        public IList<SmallValveOperateQuery> PostGetSmallValveOperates(SmallValveOperateCon svoc)
        {
            svoq = new SmallValveOperateQuery();
            return svoq.GetSmallValveOperates(svoc);
        }
        /*
        [POST("GetSmallValveOperatesCount")]
        public int PostGetSmallValveOperatesCount(SmallValveOperate info)
        {
            var where = SmallValveOperateWhere(info);
            int count = rep.LoadCount(where);
            return count;
        }
        */

        [POST("AddSmallValveOperate")]
        public bool PostAddSmallValveOperate(SmallValveOperate info)
        {
            info.MRNO = BuilderMrno.GetMrnoFortbl("Tbt_SmallValveOperate");
            svo = new SmallValveOperate();
            bool result = svo.AddSmallValveOperate(info) > 0 ? true : false;
            return result;
        }

        
        [POST("EditSmallValveOperate")]
        public bool PostEditSmallValveOperate(SmallValveOperate info)
        {
            svo = new SmallValveOperate();
            bool result = svo.UpdateSmallValveOperate(info) > 0 ? true : false;
            return result;
        }
        /*
        [GET("DeleteSmallValveOperate/{code}")]
        public bool GetDeleteSmallValveOperate(string code)
        {
            bool result = rep.Delete(code);
            return result;
        }
        */
        [GET("GetSmallValveOperate/{epcno}")]
        public SmallValveOperate GetSmallValveOperate(string epcno)
        {
            svo = new SmallValveOperate();
            var result = svo.GetSmallValveOperate(epcno);
            return result;
        }
         
    }
}
